function _toConsumableArray(t) {
    if (Array.isArray(t)) {
        for (var a = 0, e = Array(t.length); a < t.length; a++) e[a] = t[a];
        return e;
    }
    return Array.from(t);
}

var g, pages, app = getApp(), page = app.page, request = app.util.request, route = app.route, toast = app.toast;

function getMyQuestion() {
    var e = 0 < arguments.length && void 0 !== arguments[0] ? arguments[0] : 1;
    request({
        url: "MyQuestion",
        data: {
            user_id: app.userInfo.id || wx.getStorageSync("userInfo").id,
            page: e,
            number: app.config.wenda_number,
            action: g.data.nav[g.data.curr].action
        },
        success: function(t) {
            wx.stopPullDownRefresh();
            var a = g.data.list;
            a && 1 != e && (t = [].concat(_toConsumableArray(a), _toConsumableArray(t))), g.setData({
                list: t
            }), t.length && e * app.config.wenda_number >= t[0].num && g.setData({
                isLoad: !0
            });
        }
    });
}

page({
    data: {
        nav: [ {
            title: "已发布",
            action: 1
        }, {
            title: "待付款",
            action: 2
        }, {
            title: "已关闭",
            action: 3
        } ],
        curr: 0,
        isLoad: !1
    },
    onLoad: function(t) {
        g = this, pages = 1, getMyQuestion();
    },
    onPullDownRefresh: function() {
        g.setData({
            isLoad: !1
        }), pages = 1, getMyQuestion();
    },
    chooseNav: function(t) {
        g.setData({
            curr: parseInt(t.currentTarget.dataset.index),
            isLoad: !1
        }, function() {
            pages = 1, getMyQuestion();
        });
    },
    onReachBottom: function() {
        !g.data.isLoad && pages++ && getMyQuestion(pages);
    }
});